cmake_minimum_required(VERSION 3.13)

#####
# Enables project() command manages VERSION variables.
if(POLICY CMP0048)
    cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)

if(POLICY CMP0071)
    cmake_policy(SET CMP0071 NEW)
endif(POLICY CMP0071)

if(POLICY CMP0072)
    cmake_policy(SET CMP0072 NEW)
endif(POLICY CMP0072)

project(robot_debug VERSION 1.0)

## Compile as C++11
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_STANDARD 11)

if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
        add_definitions(-DDEBUGMODE)
        message("Build Type: Debug ")
        # Set platform / compiler specific compile flags and checks
        set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -fPIC -Wno-unused-function -ftemplate-backtrace-limit=0 -Wno-ignored-attributes -Wno-int-in-bool-context")
else( CMAKE_BUILD_TYPE STREQUAL "Release" ) 
        message("Build Type: Release ")
endif()

# set bin folder
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)


##############################################################################
# Catkin
##############################################################################

# qt_build provides the qt cmake glue, roscpp the comms for a default talker
find_package(catkin REQUIRED COMPONENTS 
        qt_build 
        roscpp
        std_msgs
        sensor_msgs
        )
include_directories(${catkin_INCLUDE_DIRS})
# Use this to define what the package will export (e.g. libs, headers).
# Since the default here is to produce only a binary, we don't worry about
# exporting anything. 
catkin_package(
  CATKIN_DEPENDS roscpp sensor_msgs
)

##############################################################################
# Catkin  end
##############################################################################

##############################################################################
## include
##############################################################################
## lib
# # Eigen
# find_package(Eigen3 REQUIRED)
# include_directories(${EIGEN3_INCLUDE_DIR})

# # amap
# include_directories(${PROJECT_SOURCE_DIR}/amap/include)

# # ceres
# set(Ceres_DIR "${PROJECT_SOURCE_DIR}/3rdParty/lib/cmake/Ceres")

# find_package(Ceres REQUIRED)
# include_directories(${CERES_INCLUDE_DIR})

# # opencv
# find_package(OpenCV REQUIRED core imgproc calib3d highgui)
# include_directories(${OpenCV_INCLUDE_DIR})

# # laszip
# set(LASZIP_DIR "${PROJECT_SOURCE_DIR}/laszip")
# add_subdirectory(${LASZIP_DIR})

# link_directories(${PROJECT_SOURCE_DIR}/lib)

# pcl
find_package(PCL REQUIRED QUIET)
include_directories(${PCL_INCLUDE_DIRS})

include_directories(
  ${PROJECT_SOURCE_DIR}
  # ${PROJECT_SOURCE_DIR}/3rdParty/include
  ${PROJECT_SOURCE_DIR}/cc_window/include
  # ${PROJECT_SOURCE_DIR}/common/include
  # ${PROJECT_SOURCE_DIR}/pose_graph/include
)

##############################################################################
## include end
##############################################################################

# set bin folder
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# Qt settings
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5Gui REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Concurrent REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
find_package(Qt5OpenGLExtensions REQUIRED)
find_package(Qt5 COMPONENTS Network REQUIRED)

## qt
file( GLOB ui_list ${PROJECT_SOURCE_DIR}/*.ui )
file( GLOB qrc_list ${PROJECT_SOURCE_DIR}/*.qrc )

qt5_wrap_ui( generated_ui_list ${ui_list} )
qt5_add_resources( generated_qrc_list ${qrc_list} )

# 源文件
file( GLOB header_list *.h )
file( GLOB source_list *.cpp )

## 3D display
file( GLOB viewer_header_list ${PROJECT_SOURCE_DIR}/cc_window/include/*.h )
file( GLOB viewer_source_list ${PROJECT_SOURCE_DIR}/cc_window/src/*.cpp )
# file( GLOB common_header_list ${PROJECT_SOURCE_DIR}/common/include/*.h ${PROJECT_SOURCE_DIR}/common/*.hpp)
# file( GLOB common_source_list ${PROJECT_SOURCE_DIR}/common/src/*.cpp )
# file( GLOB pgo_header_list ${PROJECT_SOURCE_DIR}/pose_graph/include/*.h)
# file( GLOB pgo_source_list ${PROJECT_SOURCE_DIR}/pose_graph/src/*.cpp )



add_executable(${PROJECT_NAME} ${header_list} ${source_list} ${generated_ui_list} ${generated_qrc_list} 
            ${viewer_header_list} ${viewer_source_list} 
            # ${common_header_list} ${common_source_list}
            # ${pgo_header_list} ${pgo_source_list} 
            )

target_link_libraries(${PROJECT_NAME}  Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL Qt5::OpenGLExtensions 
                      Qt5::Concurrent Qt5::PrintSupport ${catkin_LIBRARIES} ${PCL_LIBRARIES}
                      )  
                      
# file(COPY ${PROJECT_SOURCE_DIR}/shaders/ DESTINATION ${PROJECT_SOURCE_DIR}/bin)


